import React, { useEffect } from "react";
import ReactDOM from 'react-dom';
import {
    HashRouter as Router,
    Switch,
    Route,
    Redirect
} from "react-router-dom";
import ClipboardJS from 'clipboard';
import LoginView from './view/login';
import DashBoardView from './view/dashboard';
import 'antd/dist/antd.css';
import './style.scss';

const App = () => {

    useEffect(() => {
          // add clipboard
          let clipboard = new ClipboardJS('.copy-item');

          clipboard.on('success', function (e) {
              console.info('Action:', e.action);
              console.info('Text:', e.text);
              console.info('Trigger:', e.trigger);
            
              e.clearSelection();
            });

          return () => {
            
          };
    });

    return React.createElement(
        Router, {}, (<Switch>
            <Route path="/login" component={LoginView}></Route>
            <Route path="/dashboard">
                <DashBoardView/>
            </Route>
            <Redirect from="/" to="/login"></Redirect>
        </Switch>)
    );
}

ReactDOM.render(
    <App />,
    document.getElementById('app')
);
